<jsp:useBean id="bean" class="dasregistry.updateBean" scope="session"/>
<jsp:setProperty name="bean" property="*"/>


<% String title="update registration";
   String header = title;
%>


<%@ include file="sangerheader.jsp" %>



<div id="main">
<%
	 String auto_id = request.getParameter("auto_id");
   
	int status = bean.updateMe(auto_id);
	
	if (status == 1) { 
	   %>
	updating service ... o.k.!
	<br/>
	<a href="showdetails.jsp?auto_id=<%= request.getParameter("auto_id") %>">view details</a> of the updated DAS source, 
         
	<%	String cstring = "";
		String[] caps = bean.getCapabilities() ;
		for ( int c =0; c< caps.length ; c++ ) {
		   cstring +="&capabilities="+caps[c];
		}
		String[] testCodes = bean.getTestCodes();
		String testCodeString="";
		if ((testCodes != null ) && (testCodes.length > 0 )) {
			testCodeString=testCodes[0];
		}
		%>
          <jsp:include page="validationLights.jsp">
<jsp:param name="dasurl" value="<%=bean.getDasurl()%>" />
<jsp:param name="testcode" value="<%=testCodeString%>" />
<jsp:param name="spec" value="<%=bean.getSpec()%>" />
<jsp:param name="auto_id" value="<%= auto_id %>"/>

		
 </jsp:include>
 
<!-- validateAction.jsp?spec=DAS%2F1.6E&dasurl=http%3A%2F%2Fdas.sanger.ac.uk%2Fdas%2Ftest16genes%2F&capabilities=stylesheet&capabilities=features&capabilities=types&capabilities=sequence&capabilities=entry_points&capabilities=alignment&testcode=1%3A3596168%2C3597168&auto_id=DS_876-->
           <%
	} else if (status == 0) {
		out.println("updating service ... unknown error occured.");
	} else if (status == 2) {
		out.println("server already in database, not registering a second time.");
	} else if (status == 3) {
		String cstring = "";
		String[] caps = bean.getCapabilities() ;
		for ( int c =0; c< caps.length ; c++ ) {
		   cstring +="&capabilities="+caps[c];
		}
		String[] testCodes = bean.getTestCodes();
		%>
		<font color="red">Server failed validation check! The registry validation has become more strict lately.</font> Please use the
		
		<a href="validateServer.jsp?dasurl=<%=bean.getDasurl()%><%=cstring%>&testCode=<% if ((testCodes != null ) && (testCodes.length > 0 )) out.print(testCodes[0]);%>&spec=<%=bean.getSpec()%>"> validation page</a> 
		to get more info.
		<%
	} else if (status == 4) {
		out.println("database error -  could not add server to database");
	} else if (status == 5) {
		out.println("unknown capability -  could not add server to database");
	} else if (status == 6) {
		out.println("you did not specify a valid email address!");
	} else if (status == 7) {		
	  	out.println("You did not specify a valid url!");
	} else if (status == 8) {		
	  	out.println("You did not specify a valid description!");
	} else if (status == 9) {		
	  	out.println("Could not add service. There is a problem with the coordinate system!");
	} else if (status == 10) {		
	  	out.println("you did not specify a valid capability!");
	} else if (status == 11) {
		out.print("you did not specify an accession code / segment id. It is required to test if the server gives a valid response.");
	} else if (status == 12) {
		out.print("the specified nickname is already in use, or otherwise invalid"); 
	}

	else if ( status > 999) {
				
	%>
		server registered successfully!
		
		<p>the key to remove this server, or update the lease of this server is:</p>
		<p><b><%=status%></b></p>
		If you forget this key, you can request it again at the remove service or renew lease pages.
	<%
	} else {
		out.println(" an unknown error occured - received status " + status);
	}


%>
</div>
</div>
<%@ include file="sangerfooter.jsp" %>


  </body>
</html>

